function initTable(e, t, o) {
	"use strict"; !
	function() {
		$("#user_list").bootstrapTable({
			url :  basePath+ "/sysUser/queryUser",
			method: "post",
			queryParams:queryParams,	
			contentType: "application/x-www-form-urlencoded",
			pageNumber: 1,
			pageSize: 10,
			pageList: [5, 10, 20, 50, 100],
			pagination: !0,
			sidePagination: "server",
			search: 0,
			showRefresh: !0,
			showToggle: !0,
			showColumns: !0,
			showExport:!0,
			striped: !0,
			toolbar: "#listToolbar",
			iconSize: "outline",
			icons: {
				refresh: "glyphicon-repeat",
				toggle: "glyphicon-list-alt",
				columns: "glyphicon-list",
				export: 'glyphicon-export'
			},
			responseHandler:function(data) {
				return data
			},

		   silent: true,
		   idField: "id",
		   formatExport: function () {
 	            return '导出';
 	       },
 		   formatLoadingMessage: function () {
  			   return "请稍等，正在加载中...";
  		   },
		   formatNoMatches: function () {
			   return '无符合条件的记录';
  		   },
  		   onLoadError: function (data) {
  			   $('#user_list').bootstrapTable('removeAll');
 		   },
  		   onClickRow: function (row) {
  		   }
		});
			$(".glyphicon-plus").parent().click(function(){
				// 点击新增跳到新增页面
				//alert(basePath+'/system/sysUser/userBatchAdd.jsp');
				location.href = basePath+'/system/sysUser/user_add.jsp';
	        });
		    $(".glyphicon-edit").parent().click(function(){
			    alter();
	        });
		    //重置密码
		    $(".glyphicon-editPass").parent().click(function(){
		    	 var userId=getSelectIds();
		    	 if(userId.length>1){
		    		 	toastr.warning("只能选择一条数据修改！");
		    		 	return false;
		    		 }else if(userId.length<1){
		    		 	toastr.warning("请选择一条数据修改！");
		    		 	return false;
		    		 }else{
		    				$.ajax({
		   		   			 type: "POST",
		   		   			url :  basePath+ "/sysUser/queryUserName",
		   		   			 data: {
		   		   				'userId':userId[0]
		   		   				 },
		   		   			 success: function(msg){
		   		   				console.log(msg.count)
		   		   				if(msg.count==0){
		   		   				location.href=basePath+"/system/sysUser/user_pass.jsp?userId="+userId[0];
		   		   				}else{
		   		   					toastr.warning("没有权限重置密码！");
		   		   				 	return false;
		   		   				}
		   		   				
		   		   			   }
		   		   		});
		    		 }
		    	
		    	 
		    	 
		    	 
		    	
	        });
		    
		    
			$(".glyphicon-remove").parent().click(function(){
				stopById();
			});
			$('#toolbar').change(function () {
 			$("#listToolbar").bootstrapTable("refreshOptions",{exportDataType: $(this).val()});
         });			
 	} ()
} (document, window, jQuery);
  
 function queryParams(pageReqeust) {
  	if(pageReqeust.limit){
		pageReqeust.pageNum = pageReqeust.offset/pageReqeust.limit + 1;
	}else{
		pageReqeust.limit = 0;
 	}
    pageReqeust.tableName='user_list';
    pageReqeust.operType='apply';
    pageReqeust.userStatus='0,1';
    return pageReqeust;
  }
 
 
 function formatterUserStatus(value,rowData,index){
 	 if(value == '0'){
			return '活动';
		}else if(value == '1'){
			return '禁用';
		}
 }
 
 function indexFormatter(value, row, index) { 
		options = $("#user_list").bootstrapTable("getOptions");
		rowStart = (options.pageNumber-1)*options.pageSize;
	    return rowStart+index+1;  
}
 
 function nameFormatter(value, row, index) { 
	 return '<a href="'+basePath+'/system/sysUser/userInfoTab.jsp?user_id=' + row.userId + '&parentId=userBatchApply'+ '">' + value + '</a>';
}

 function alter(){
	 var userId=getSelectIds();
	 if(userId.length>1){
	 	toastr.warning("只能选择一条数据修改！");
	 	return false;
	 }else if(userId.length<1){
	 	toastr.warning("请选择一条数据修改！");
	 	return false;
	 }else{
	 	location.href=basePath+"/system/sysUser/user_edit.jsp?userId="+userId[0];
	 }
	 }

	 function del(){
	 var ids=getSelectIds();
	 if(ids.length>=1){
	 	deleteByIds(ids.join(","));
	 }else{
	 	toastr.warning("请选择需要操作数据！");
	 	return false;
	 }
	 }

	 function stopById(){
	 var ids=getSelectIds();
	 if(ids.length>=1){
		 stopByIds(ids.join(","));
	 }else{
	 	toastr.warning("请选择需要操作数据！");
	 	return false;
	 }
	 }

	 function getSelectIds(){
	 	var data = $("#user_list").bootstrapTable('getSelections');
	 	var ids =new Array();
	 	if(data.length>=1){
	 		for(var i=0;i<data.length;i++){
	 	   	ids.push(data[i].userId);
	 	   }
	 	}	return ids;
	 }

	 function getSubmitSelectIds(){
	 var data = $("#user_list").bootstrapTable('getSelections');
	 var ids =new Array();
	 if(data.length>=1){
	 	for(var i=0;i<data.length;i++){
	 		//if(data[i].state=='1'){
	 			ids.push(data[i].id);
	   // }
	 }
	 }
	 return ids;
	 }

	 function deleteByIds(ids){
	 	swal({
	 		title: "您确定要删除这条信息吗?",
	 		text: "您将永久删除这条信息!",
	 		type: "warning",
	 		showCancelButton: true,
	 		confirmButtonColor: "#DD6B55",
	 		confirmButtonText: "是的,我要删除!",
	 		cancelButtonText: "让我再考虑一下...",
	 		closeOnConfirm: false,
	 		closeOnCancel: true
	 		},
	 		function(isConfirm){
	 			if (isConfirm) {
	 				$.ajax({
	 					 type: "POST",
	 					 url :  basePath+ "/sysUser/delete",
	 					 data: {'ids':ids,'tableName':'user_list'},
	 					 success: function(msg){
	 						   if(msg.success){
	 							   swal("删除成功！", "您已经永久删除了这条信息。", "success");
	 								setTimeout(function(){
	 									$("#user_list").bootstrapTable("refresh");
	 								},1000);
	 							}else{
	 								swal("删除失败！", "action错误。", "error");
	 								setTimeout(function(){
	 									$("#user_list").bootstrapTable("refresh");
	 								},1000);
	 							}
	 					   }
	 					});
	 				}else {
	 				$("#user_list").bootstrapTable("refresh");
	 				}
	 			});
	 }


	 function stopByIds(ids){
	 	$.ajax({
	 		 type: "POST",
	 		 url :  basePath+ "/sysUser/stop",
	 		 data: {'ids':ids},
	 		 success: function(msg){
	 			   if(msg.success){
	 				   toastr.success("禁用成功！");
	 				   $("#user_list").bootstrapTable("refresh");
	 				}else{
	 					toastr.warning("禁用失败！");
	 					$("#user_list").bootstrapTable("refresh");
	 				}
	 		   }
	 		});
	 	}
	 
		function templeExport(){
			$('#tempExport')[0].action =basePath+ '/sysUser/tempExport';	
			$('#tempExport')[0].submit();
		}
		function excelImport(){
		    $('#importExcel').modal({remote: basePath+ '/system/sysUser/userImport.jsp'});
		}
